//
//  HomePageTableViewCell.m
//  SinceLe
//
//  Created by 李元喜 on 15/11/16.
//  Copyright © 2015年 李元喜. All rights reserved.
//

#import "HomePageTableViewCell.h"
#import "HomePageCollectionViewCell.h"
@interface HomePageTableViewCell ()<UICollectionViewDataSource, UICollectionViewDelegate>
@property (strong, nonatomic) UICollectionViewFlowLayout *Flow;
@property (strong, nonatomic) UICollectionView *collectionView;
@end

@implementation HomePageTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _Flow = [[UICollectionViewFlowLayout alloc] init];
        self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) collectionViewLayout:_Flow];
//        self.headerView = [[[NSBundle mainBundle] loadNibNamed:@"headerView" owner:nil options:nil] firstObject];
//        [self.contentView addSubview:_headerView];
        [self.contentView addSubview:_collectionView];
        
    }
    
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    [self loadcollectionView];
}

- (void)loadcollectionView
{
    //布局类 控制每一个cell的样式
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    _collectionView.frame = CGRectMake(10,  10, self.frame.size.width, 600);
    
    _Flow.itemSize = CGSizeMake(self.frame.size.width / 2 - 10, 200);
    //改变上下之间的大小(默认的是10)
    _Flow.minimumLineSpacing = 10;
    // 设置两个item中间的大小
    _Flow.minimumInteritemSpacing = 10;
    _collectionView.showsHorizontalScrollIndicator = NO;
    _collectionView.showsVerticalScrollIndicator = NO;
    _collectionView.bounces = NO;
    _Flow.sectionInset = UIEdgeInsetsMake(0, 5, 0, 5);
    self.collectionView.backgroundColor = [UIColor whiteColor];
    UINib *nib = [UINib nibWithNibName:@"HomePageCollectionViewCell" bundle:nil];
    [self.collectionView registerNib:nib forCellWithReuseIdentifier:@"cell"];
    
    
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    
    return 4;
    
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    HomePageCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];

    return cell;
    
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    
}

@end
